/**
 * 文件描述如下：
 * 1. 处理交通流量参数页面的数据
 */

const data_top = [
  { id: 0, key: 'b3-period', parentNode: null, name: 'b3发送周期(秒)', showType: 'input', inputType: 'uint' },
  { id: 1, key: 'b4-period', parentNode: null, name: 'b4发送周期 (n * 60 秒)', showType: 'input', inputType: 'uint' },
  { id: 2, key: 'b5-period', parentNode: null, name: 'b5事件间隔发送时间', showType: 'input', inputType: 'uint' },
]

// 处理交通流量页面的数据
const data_1 = {
  title: '违停',
  data: [{ id: 0, key: 'continue-time', parentNode: 'illegal-stop', name: '持续时间', showType: 'input', inputType: 'double' }],
}
const data_2 = {
  title: '停驶',
  data: [{ id: 0, key: 'hit-count', parentNode: 'stop-driving', name: '触发事件连续帧数阈值', showType: 'input', inputType: 'double' }],
}
const data_3 = {
  title: '机动车逆行',
  data: [{ id: 0, key: 'continue-time', parentNode: 'retrograde-for-motor', name: '持续时间', showType: 'input', inputType: 'double' }],
}
const data_4 = {
  title: '非机动车逆行',
  data: [{ id: 0, key: 'continue-time', parentNode: 'retrograde-for-nonmotor', name: '持续时间', showType: 'input', inputType: 'double' }],
}

const data_5 = {
  title: '机动车占用非机动车道',
  data: [{ id: 0, key: 'hit-count', parentNode: 'motor-occupy-nonmotor-lane', name: '触发事件连续帧数阈值', showType: 'input', inputType: 'double' }],
}

const data_6 = {
  title: '非机动车越线停车',
  data: [{ id: 0, key: 'hit-count', parentNode: 'nonmotor-parking-over-line', name: '触发事件连续帧数阈值', showType: 'input', inputType: 'double' }],
}

const data_7 = {
  title: '不按车道导向行驶',
  data: [{ id: 0, key: 'hit-count', parentNode: 'not-following-lane-guide', name: '触发事件连续帧数阈值', showType: 'input', inputType: 'double' }],
}

const data_8 = {
  title: '机动车超速',
  data: [{ id: 0, key: 'continue-time', parentNode: 'motor-over-speed', name: '持续时间', showType: 'input', inputType: 'double' }],
}

const data_9 = {
  title: '抛撒物',
  data: [{ id: 0, key: 'hit-count', parentNode: 'spill', name: '触发事件连续帧数阈值', showType: 'input', inputType: 'double' }],
}

const data_10 = {
  title: '施工',
  data: [{ id: 0, key: 'hit-count', parentNode: 'roadwork', name: '触发事件连续帧数阈值', showType: 'input', inputType: 'double' }],
}

const data_11 = {
  title: '非机动车占用机动车道',
  data: [{ id: 0, key: 'hit-count', parentNode: 'nonmotor-occupy-motor-lane', name: '触发事件连续帧数阈值', showType: 'input', inputType: 'double' }],
}

const data_12 = {
  title: '车车事故',
  data: [{ id: 0, key: 'continue-time', parentNode: 'cars-accident', name: '持续时间', showType: 'input', inputType: 'double' }],
}

const data_13 = {
  title: '非机动车不带头盔',
  data: [{ id: 0, key: 'hit-count', parentNode: 'nonmotor-no-helmets', name: '触发事件连续帧数阈值', showType: 'input', inputType: 'double' }],
}

const data_14 = {
  title: '人车事故',
  data: [{ id: 0, key: 'continue-time', parentNode: 'people-cars-accident', name: '持续时间', showType: 'input', inputType: 'double' }],
}

const data_15 = {
  title: '行人闯红灯',
  data: [{ id: 0, key: 'hit-count', parentNode: 'people-run-red-light', name: '触发事件连续帧数阈值', showType: 'input', inputType: 'double' }],
}

const data_16 = {
  title: '机动车慢行',
  data: [{ id: 0, key: 'stroll-time', parentNode: 'motor-stroll', name: '持续时间', showType: 'input', inputType: 'double' }],
}

const data_17 = {
  title: '压线',
  data: [{ id: 0, key: 'hit-count', parentNode: 'cross-line', name: '触发事件连续帧数阈值', showType: 'input', inputType: 'double' }],
}

const data_18 = {
  title: '机动车违规变道',
  data: [{ id: 0, key: 'continue-time', parentNode: 'change-lanes', name: '持续时间', showType: 'input', inputType: 'double' }],
}

const data_19 = {
  title: '机动车闯红灯',
  data: [{ id: 0, key: 'hit-count', parentNode: 'motor-run-red-light', name: '触发事件连续帧数阈值', showType: 'input', inputType: 'double' }],
}
const data_20 = {
  title: '非机动车闯红灯',
  data: [{ id: 0, key: 'hit-count', parentNode: 'nonmotor-run-red-light', name: '触发事件连续帧数阈值', showType: 'input', inputType: 'double' }],
}

// 聚合数据
const data_main = [data_1, data_2, data_3, data_4, data_5, data_6, data_7, data_8, data_9, data_10, data_11, data_12, data_13, data_14, data_15, data_16, data_17, data_18, data_19, data_20]
export const dataProcessingTransportation = (params) => {
  if (!params) return
  // 头部的块
  data_top.forEach((item) => {
    item.value = item.parentNode ? params[item.parentNode][item.key] : params[item.key]
  })

  data_main.forEach((item) => {
    item.data.forEach((item2) => {
      item2.value = item2.parentNode ? params[item2.parentNode][item2.key] : params[item2.key]
    })
  })

  return { data_top, data_main }
}
